package views;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import multiformat.Calculator;

/**
 * 
 * @author Alexander Jeurissen, Dustin Meijer
 *
 */

public class StackView extends JFrame implements ActionListener {

	private static final long serialVersionUID = 1L;
	
	private Calculator calculator;
	private JTextArea stack;
	private JScrollPane pane;
	
	
	public StackView() {
				
		this.setLayout(new GridLayout(1,1));
		this.setSize(215,250);

		
		this.setTitle("StackView:");
		
		stack = new JTextArea();
		stack.setEditable(false);
		stack.setBackground(Color.WHITE);
		
		pane = new JScrollPane(stack);

		this.add(pane);
		
		this.setResizable(false);
		this.validate();
		this.setDefaultCloseOperation(HIDE_ON_CLOSE);
		
	}
	
	/**
	 * This method will make the HistoryView visible.
	 */
	public void showframe() {
		this.setVisible(true);
	}
	
	public void actionPerformed( ActionEvent e ) {
		calculator = (Calculator)e.getSource();
		if(e.getActionCommand() == "stack") {
		   showframe();
		}
		stack.setText(calculator.getStackContent());   
	}
		 
	 

		
}
